package xw4g08;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFHandler;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFParseException;
import org.openrdf.rio.RDFParser;
import org.openrdf.rio.Rio;

public class Converter {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		File file = new File(Configuration.IN_DIR,"modified_10.ttl");
		RDFFormat inFormat = Rio.getParserFormatForFileName(file.getName());
		RDFParser parser = Rio.createParser(inFormat);
		RDFFormat outFormat = RDFFormat.N3;
		FileOutputStream out;
		try {
			out = new FileOutputStream(new File(Configuration.OUT_DIR,file.getName().substring(0, file.getName().lastIndexOf("."))+".n3"));
			RDFHandler writer = Rio.createWriter(outFormat, out);
			parser.setRDFHandler(writer);
			parser.parse(new FileInputStream(file), "xw4g08");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (RDFParseException e) {
			e.printStackTrace();
		} catch (RDFHandlerException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		

	}

}
